/*
@data: 2023/7/10
@author: North
@desc: test
*/
/*
var userList = map[string]map[string]string{
		"root":{"password":"123456", "tel":"158xxxxxxxx"},
		"admin":{"password":"123456", "tel":"158xxxxxxxx"},
		"xiaoming":{"password":"123456", "tel":"158xxxxxxxx"}}
	输入用户名密码，进行验证，验证成功后，输出手机号码
 */
package main

import "fmt"

func main()  {
	//设置用户信息
	var userList = map[string]map[string]string{
		"root":{"password":"123456", "tel":"158xxxxxxxx"},
		"admin":{"password":"12356", "tel":"158xxxxxxxx"},
		"xiaoming":{"password":"12346", "tel":"158xxxxxxxx"}}
	//定义要输入的变量，和判断信号
	var name,password string
	var sigin = "error"
	print("输入用户名：")
	fmt.Scan(&name)

	//遍历用户信息
	for usename,userinfo := range userList{
		//判断是否存在该用户
		if name == usename {
			print("输入密码：")
			fmt.Scan(&password)
			//判断密码是否正确
			if password == userinfo["password"]{
				fmt.Printf("tel：%s\n",userinfo["tel"])
				sigin = "success"
			} else {
				print("密码错误！！！")
				sigin = ""
			}
		}
	}
	if sigin == "error" {
		print("用户不存！！！")
	}

}